// 视频播放上报
const reportPlayerMixin = {
	data(){
		return{
			//计时器 定时上报
			timer:'',
			//计时时间 
			playTime:0,
			//计时间隔,多长时间提交一次
			costTime:0,
			//播放时长上报次数
			reportIndex: 1,
		}
	},
	onUnload() {
		this.clearReportPlayer();
	},
	onHide() {
		this.clearReportPlayer();
	},
	methods: {
		// 播放上报
		reportPlayer(){
			//定时器开始计时
			this.playTime = 0
			this.timer = setInterval(()=>{
				if(this.playTime%this.costTime == 0){
					reportPlayTime(this.reportIndex, this.classId,this.Id,this.costTime,3);
					this.reportIndex++
				}
				this.playTime++
			}, 1000 * 60)
		},
		clearReportPlayer(){
			clearInterval(this.timer);
		}
	}
}

export default reportPlayerMixin;